package data;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class DeviceProperties implements Serializable {
	private int mode, midiIn, midiOut;
	
	public DeviceProperties() {
		mode = 3;
		midiIn = -1;
		midiOut = -1;
	}

	/*public DeviceProperties(int mode, int midiIn, int midiOut) {
		this.mode = mode;
		this.midiIn = midiIn;
		this.midiOut = midiOut;
	}*/
	
	public int getMode() {
		return mode;
	}
	
	public int getMidiIn() {
		return midiIn;
	}
	
	public int getMidiOut() {
		return midiOut;
	}
	
	public void setMode(int mode) {
		this.mode = mode;
	}
	
	public void setMidiIn(int midiIn) {
		this.midiIn = midiIn;
	}
	
	public void setMidiOut(int midiOut) {
		this.midiOut = midiOut;
	}

	@Override
	public void serialize(OutputStream os) {
		try {
			os.write(mode);
			os.write(midiIn);
			os.write(midiOut);
			System.out.println("" + mode);
			System.out.println("" + midiIn);
			System.out.println("" + midiOut);
		} 
		catch (IOException ioe) {
			ioe.printStackTrace();
		}		
	}

	@Override
	public void deserialize(InputStream is) {
		try {
			mode = is.read();
			midiIn = is.read();
			midiOut = is.read();
			System.out.println("" + mode + " " + midiIn + " " + midiOut);
		} 
		catch (IOException ioe) {
			ioe.printStackTrace();
		}		
	}
	
	@Override
	public String toString() {
		return "" + mode + " " + midiIn + " " + midiOut;
	}
}
